package com.lb.statck.util;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.common.auth.CredentialsProviderFactory;
import com.aliyun.oss.common.auth.EnvironmentVariableCredentialsProvider;
import com.aliyuncs.exceptions.ClientException;
import org.springframework.beans.factory.annotation.Value;

public class OssClientUtil {
   // private static final String ENDPOINT = "https://oss-cn-hangzhou.aliyuncs.com"; // 替换为你的OSS Endpoint
   // private static final String ACCESS_KEY_ID = "你的AccessKeyId"; // 替换为你的AccessKeyId
   // private static final String ACCESS_KEY_SECRET = "你的AccessKeySecret"; // 替换为你的AccessKeySecret

    @Value("${ali.oss.ENDPOINT}")
    private static String ENDPOINT;
    @Value("${ali.oss.ACCESS_KEY_ID}")
    private static String ACCESS_KEY_ID;
    @Value("${ali.oss.ACCESS_KEY_SECRET}")
    private static String ACCESS_KEY_SECRET;


    public static OSS createOssClient() throws ClientException {
        EnvironmentVariableCredentialsProvider credentialsProvider =
                CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
        return new OSSClientBuilder().build(ENDPOINT, ACCESS_KEY_ID, ACCESS_KEY_SECRET);
    }
}
